import axios from "axios";

export default (await import('vue')).defineComponent({
name: "TopView",
data() {
return {
//轮播图
carousels: [
{ id: 1, goodId: '2', img: 'https://img.alicdn.com/imgextra/i1/6000000002979/O1CN01q684lx1XsQlTV9UP0_!!6000000002979-0-octopus.jpg' },
{ id: 2, goodId: '1', img: 'https://gw.alicdn.com/bao/uploaded/i4/2209919053565/O1CN01zV8zm11cCoqwCfEiU_!!2209919053565.jpg_300x300q90.jpg_.webp' },
{ id: 2, goodId: '3', img: 'https://img.alicdn.com/imgextra/i4/6000000004111/O1CN01U5LhYZ1gEt6vynoCN_!!6000000004111-0-octopus.jpg' },
{ id: 2, goodId: '4', img: 'https://img.alicdn.com/imgextra/i2/6000000001560/O1CN01azSWQn1NOWkYxSdas_!!6000000001560-0-octopus.jpg' },
{ id: 2, goodId: '5', img: 'https://img.alicdn.com/imgextra/i1/6000000005991/O1CN01jfz8m61u7vi92sd5v_!!6000000005991-0-octopus.jpg' },
],
//推荐商品
good: [],

//分类icon，每个icon包含id、value、categories对象数组.category：id，name
icons: [
{
"icon": <i class="el-icon-shopping-bag-1"></i>,
"id": 1,
"value": "",
"categories": [
{
"id": 1,
"name": "女装"
},
{
"id": 2,
"name": "男装"
}
]
},
{
"icon": "icon_url2",
"id": 2,
"value": "",
"categories": [
{
"id": 2,
"name": "女鞋"
},
{
"id": 3,
"name": "男鞋"
}
]
},
{
"icon": "icon_url3",
"id": 3,
"value": "",
"categories": [
{
"id": 1,
"name": " 文具"
},
{
"id": 3,
"name": "书籍"
}
]
},
{
"icon": "icon_url4",
"id": 4,
"value": "",
"categories": [
{
"id": 4,
"name": "零食"
},
{
"id": 5,
"name": "饮料"
}
]
},
{
"icon": "icon_url5",
"id": 5,
"value": "",
"categories": [
{
"id": 5,
"name": "手机"
},
{
"id": 6,
"name": "数码"
}
]
},
{
"icon": "icon_url6",
"id": 6,
"value": "",
"categories": [
{
"id": 1,
"name": "美妆"
},
{
"id": 6,
"name": "个护"
}
]
}
],
//搜索内容
searchText: '',
};
},
components: {
search,
},

methods: {
handleSearch(text) {
this.searchText = text;
this.$router.push({ path: '/goodList', query: { searchText: this.searchText } });
},
created() {
axios.get("http://localhost:8089/business/selectShelvesGoodsInfo?storeId=1&page=1&pageSize=1")
.then((res) => {
if (res.status === 200) {
this.good = res.data;
} else {
this.$message.error(res.data.msg);
}
})
.catch((error) => {
console.error(error);
});

this.request.get("/api/icon").then(res => {
if (res.code === '200') {
this.icons = res.data;
}
});
this.request.get("/api/carousel").then(res => {
if (res.code === '200') {
this.carousels = res.data;
}
});
},
}
});
